package dao;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import vo.DepartmentVO;
import vo.MemberVO;

@Repository
public class RankDaoImpl implements RankDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public List<MemberVO> memberMonthRank(String type) {
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		if(type.equals("year")){
			map.put("type", 2);
		}else if(type.equals("month")){
			map.put("type", 5);
		}else if(type.equals("day")){
			map.put("type", 8);
		}
		return sqlSessionTemplate.selectList("rank.memberMonthRank", map);
	}

	@Override
	public List<DepartmentVO> deptMontRank(String type) {
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		if(type.equals("year")){
			map.put("type", 2);
		}else if(type.equals("month")){
			map.put("type", 5);
		}else if(type.equals("day")){
			map.put("type", 8);
		}
		return sqlSessionTemplate.selectList("rank.deptMonthRank", map);
	}

	@Override
	public int todayMemberCount() {
		return sqlSessionTemplate.selectOne("rank.todayMemberCount");
	}

	@Override
	public int todayStairCount() {
		return sqlSessionTemplate.selectOne("rank.todayStairCount");
	}

}
